package TimerLogs;

import org.eclipse.swt.widgets.*;

import Logs.Logger;

public class LabelLog implements Logger
{
	private long _startTime;
	private String _lastMessage;
	private Label _label;
	private boolean enabled;
	
	public LabelLog(Label label)
	{
		_label = label;
	}
	
	public void Start()
	{
		enabled = true;
		_startTime = System.nanoTime();
		_lastMessage = "";
	}
	
	public void Stop()
	{
		if (enabled)
		{
			enabled = false;
			_label.setText(String.format("[took %d ms]: %s", new Long(System.nanoTime() - _startTime) / 1000000, _lastMessage));
		}
	}
	
	public void Log(String what)
	{
		_lastMessage = new String(what);
	}
}
